package com.pucong.gitee.database.backup;

import com.pucong.gitee.database.backup.utils.AppBanner;
import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.util.StopWatch;

@SpringBootApplication
@MapperScan("com.pucong.gitee.database.backup.**.mapper")
public class AutoDatabaseApplication {
    private static final Logger logger = LoggerFactory.getLogger(AutoDatabaseApplication.class);

    public static void main(String[] args) {
        StopWatch stopWatch = new StopWatch();
        stopWatch.start();
        ConfigurableApplicationContext context = new SpringApplicationBuilder(AutoDatabaseApplication.class)
                .logStartupInfo(false)
                .banner(new AppBanner())
                .run(args);
        stopWatch.stop();
        Integer port = context.getBean(ServerProperties.class).getPort();

        logger.info("页面访问地址: http://127.0.0.1:{}/auto-database/views/index.html", port);
        logger.info("Swagger地址: http://127.0.0.1:{}/auto-database/doc.html", port);
        logger.info("h2 地址: http://127.0.0.1:{}/auto-database/h2-console", port);
        logger.info("服务启动完成，耗时:{}s", stopWatch.getTotalTimeSeconds());
    }
}
